/**
 * Created by zhangqingxi on 2017-04-06.
 */
var modelPath=ROOT_PATH+'/environmental/waterWaste/registration/';


//初始化部门
function initDept() {

    $('#deptId').combotree({
        url: ROOT_PATH+'/permission/department/getDepartmentTree.shtml?parentId=0',
        required:true,
        editable:false,
        prompt:'请选择',
        onChange:function (newValue,oldValue) {
            $('#deviceId').combobox({
                value:''
            });
            initDevice(newValue);
        }
    });
}
//初始化 装置deviceId
function initDevice(deptId) {
    $('#deviceId').combobox({
        url:deviceByDeptId+deptId,
        prompt:'请选择',
        required:true,
        editable:false,
        valueField:'id',
        textField:'text'
    });
}
//初始化废水名称
function initWaterWasteName() {
    $('#waterWasteNameId').combobox({
        url:dictionaryByCode+waterWaste,
        prompt:'请选择',
        required:true,
        editable:false,
        valueField:'id',
        textField:'text'
    });
}
//初始化回用水 reuseWaterPlaceId
function initReuseWaterPlace() {
    $('#reuseWaterPlaceId').combobox({
        url:dictionaryByCode+reuseWaterPlace,
        prompt:'请选择',
        //required:true,
        editable:false,
        valueField:'id',
        textField:'text'
    });
}
//初始化排放去处 reuseWaterPlaceId
function initDrainagePlace() {
    $('#drainagePlaceId').combobox({
        url:dictionaryByCode+drainagePlace,
        prompt:'请选择',
       // required:true,
        editable:false,
        valueField:'id',
        textField:'text'
    });
}
//初始化监测点 monitoringPointId
function initMonitoringPoin() {
    $('#monitoringPointId').combogrid({
        required:true,
        editable:false,
        readonly:false,
        panelWidth:500,
        prompt:'请选择',
        idField:'id',
        textField:'name',
        queryParams:{
            sort:'d.addTime',
            order:'desc'
        },
        fitColumns:true,
        pagination:true,
        rownumbers:true,
        singleSelect:true,
        sortOrder:true,
        striped:true,
        url:findMonitoringPoint,
        columns:[[
            {field:'name',title:'监测点名称',width:100},
            {field:'contaminantsTypeName',title:'污染物类型',width:100},
            {field:'controlLevelName',title:'控制级别',width:100},
            {field:'remarks',title:'备注',width:100}
        ]]
    });
}
//部门加载完成之后的事件
function deptLoadSuccess() {

    var $deptVal= ($('#deptId').val());
    initDevice($deptVal);
    //加载部门
    initDept();

}

